Skip to content

Commit 7303c31

Browse files
committed
Issue #111: Add a show on content change action to the toolbar for all Microclimate consoles
1 parent 9802635 commit 7303c31

File tree

6 files changed

+117
-0
lines changed

6 files changed

+117
-0
lines changed

dev/com.ibm.microclimate.core/src/com/ibm/microclimate/core/internal/console/SocketConsole.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class SocketConsole extends IOConsole {
3030

3131
private IOConsoleOutputStream outputStream;
3232
private boolean isInitialized = false;
33+
private boolean showOnUpdate = false;
3334

3435
public SocketConsole(String consoleName, ProjectLogInfo logInfo, MicroclimateApplication app) {
3536
super(consoleName, MicroclimateConsoleFactory.MC_CONSOLE_TYPE,
@@ -58,6 +59,9 @@ public void update(String contents, boolean reset) throws IOException {
5859

5960
MCLogger.log("Appending contents to log: " + this.getName()); // $NON-NLS-1$
6061
outputStream.write(contents);
62+
if (showOnUpdate) {
63+
activate();
64+
}
6165
}
6266

6367
@Override
@@ -75,4 +79,8 @@ protected void dispose() {
7579

7680
super.dispose();
7781
}
82+
83+
public void setShowOnUpdate(boolean value) {
84+
showOnUpdate = value;
85+
}
7886
}

dev/com.ibm.microclimate.ui/plugin.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,15 @@
260260
markerType="com.ibm.microclimate.core.validationMarker"
261261
class="com.ibm.microclimate.ui.internal.marker.MicroclimateMarkerResolutionGenerator"/>
262262
</extension>
263+
264+
<extension point="org.eclipse.ui.console.consolePageParticipants">
265+
<consolePageParticipant
266+
id="com.ibm.microclimate.ui.socketConsolePageParticipant"
267+
class="com.ibm.microclimate.ui.internal.console.SocketConsolePageParticipant">
268+
<enablement>
269+
<instanceof value="com.ibm.microclimate.core.internal.console.SocketConsole"/>
270+
</enablement>
271+
</consolePageParticipant>
272+
</extension>
263273

264274
</plugin>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2019 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.ibm.microclimate.ui.internal.console;
13+
14+
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15+
import org.eclipse.debug.ui.DebugUITools;
16+
import org.eclipse.jface.action.Action;
17+
import org.eclipse.jface.action.IAction;
18+
19+
import com.ibm.microclimate.core.internal.console.SocketConsole;
20+
import com.ibm.microclimate.ui.MicroclimateUIPlugin;
21+
import com.ibm.microclimate.ui.internal.messages.Messages;
22+
23+
public class ShowOnContentChangeAction extends Action {
24+
25+
SocketConsole console;
26+
27+
public ShowOnContentChangeAction(SocketConsole console) {
28+
super(Messages.ShowOnContentChangeAction, IAction.AS_CHECK_BOX);
29+
setToolTipText(Messages.ShowOnContentChangeAction);
30+
setId(MicroclimateUIPlugin.PLUGIN_ID + ".ShowOnContentChangeAction"); //$NON-NLS-1$
31+
setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STANDARD_OUT));
32+
this.console = console;
33+
}
34+
35+
@Override
36+
public void run() {
37+
console.setShowOnUpdate(isChecked());
38+
}
39+
40+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2019 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.ibm.microclimate.ui.internal.console;
13+
14+
import org.eclipse.jface.action.IToolBarManager;
15+
import org.eclipse.ui.IActionBars;
16+
import org.eclipse.ui.console.IConsole;
17+
import org.eclipse.ui.console.IConsoleConstants;
18+
import org.eclipse.ui.console.IConsolePageParticipant;
19+
import org.eclipse.ui.part.IPageBookViewPage;
20+
21+
import com.ibm.microclimate.core.internal.console.SocketConsole;
22+
23+
public class SocketConsolePageParticipant implements IConsolePageParticipant {
24+
25+
@Override
26+
public <T> T getAdapter(Class<T> arg0) {
27+
return null;
28+
}
29+
30+
@Override
31+
public void activated() {
32+
// Empty
33+
}
34+
35+
@Override
36+
public void deactivated() {
37+
// Empty
38+
}
39+
40+
@Override
41+
public void dispose() {
42+
// Empty
43+
}
44+
45+
@Override
46+
public void init(IPageBookViewPage page, IConsole console) {
47+
if (console instanceof SocketConsole) {
48+
ShowOnContentChangeAction contentChange = new ShowOnContentChangeAction((SocketConsole)console);
49+
50+
// Contribute to the toolbar
51+
IActionBars actionBars = page.getSite().getActionBars();
52+
IToolBarManager mgr = actionBars.getToolBarManager();
53+
mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, contentChange);
54+
}
55+
}
56+
57+
}

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class Messages extends NLS {
7171
public static String ShowAllLogFilesAction;
7272
public static String HideAllLogFilesAction;
7373
public static String ErrorOnShowLogFileDialogTitle;
74+
public static String ShowOnContentChangeAction;
7475

7576
public static String ActionNewConnection;
7677

dev/com.ibm.microclimate.ui/src/com/ibm/microclimate/ui/internal/messages/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ShowLogFilesMenu=&Show Log Files
6464
ShowAllLogFilesAction=&Show All
6565
HideAllLogFilesAction=&Hide All
6666
ErrorOnShowLogFileDialogTitle=An error occurred while opening or closing the stream for the log file.
67+
ShowOnContentChangeAction=Show on Content Change
6768

6869
ActionNewConnection=&New Microclimate Connection
6970

0 commit comments

Comments
 (0)