RTSDK: refactoring View for supporting saveLog in Terminal
authorJaeMin Kim <jm.jemin.kim@samsung.com>
Fri, 14 Apr 2017 07:33:39 +0000 (16:33 +0900)
committerJaeMin Kim <jm.jemin.kim@samsung.com>
Mon, 17 Apr 2017 04:12:13 +0000 (13:12 +0900)
Created RtTerminalsView to access SerialConnector.
RtExtensionView is Wrapping TerminalsView with RtTerminalsView.
This is because the parent class is required to access the Serial
Connector.

Change-Id: I68124d0788dd3f70d51f22b82656888272ff6181
Signed-off-by: JaeMin Kim <jm.jemin.kim@samsung.com>
rt-ide/org.eclipse.tm.terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/internal/dialogs/LaunchTerminalSettingsDialog.java
rt-ide/org.eclipse.tm.terminal/plugins/org.eclipse.tm.terminal.view.ui/src/org/eclipse/tm/terminal/view/ui/tabs/TabFolderToolbarHandler.java
rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view.png [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view_sel.png [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/plugin.xml
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/perspectives/TizenRTPerspective.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/RtTerminalsViewEx.java [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/TabFolderToolbarHandlerEx.java [new file with mode: 0644]

index 6afb07f..88b2197 100644 (file)
@@ -595,6 +595,11 @@ public class LaunchTerminalSettingsDialog extends TrayDialog {
        }
        data = new HashMap<String, Object>();
 
+       /* Tizen */
+       // Apply RtTerminalsView instead of TerminalsView
+       data.put(ITerminalsConnectorConstants.PROP_ID, "org.tizen.rt.ide.view.RtTerminalsView");
+       /* ===== */
+
        // Store the id of the selected delegate
        String terminalLabel = terminals != null ? terminals.getText() : singleDelegateLabel;
        String delegateId = terminalLabel != null ? label2delegate.get(terminalLabel).getId() : null;
index 730233c..a9ea20a 100644 (file)
@@ -15,7 +15,6 @@ import java.util.List;
 
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -49,7 +48,7 @@ public class TabFolderToolbarHandler extends PlatformObject {
        // Reference to the selection listener
        private ToolbarSelectionChangedListener selectionChangedListener;
        // The list of actions available within the toolbar
-       private final List<AbstractTerminalAction> toolbarActions = new ArrayList<AbstractTerminalAction>();
+       protected final List<AbstractTerminalAction> toolbarActions = new ArrayList<AbstractTerminalAction>();
 
        /**
         * Default selection listener implementation.
@@ -173,12 +172,6 @@ public class TabFolderToolbarHandler extends PlatformObject {
 
                // Update actions
                updateToolbarItems(false);
-
-               /* Tizen - Add menubar */
-               // Fill the menubar
-               IMenuManager menuManager = bars.getMenuManager();
-               doFillMenubar(menuManager);
-               /* ===== */
        }
 
        /**
@@ -292,26 +285,6 @@ public class TabFolderToolbarHandler extends PlatformObject {
                });
        }
 
-       /* Tizen */
-       private void doFillMenubar(IMenuManager menuManager) {
-               // we want that at the end
-               AbstractTerminalAction pasteAction = null;
-
-               for(AbstractTerminalAction action : toolbarActions) {
-                       // Fill only copy, paste action in menubar
-                       if(action instanceof TerminalActionCopy) {
-                               menuManager.add(action);
-                       } else if(action instanceof TerminalActionPaste) {
-                               pasteAction = action;
-                       }
-               }
-               // now add to the end
-               if(pasteAction != null) {
-                       menuManager.add(pasteAction);
-               }
-       }
-       /* ===== */
-
        /**
         * Fill in the context menu content within the given manager.
         *
@@ -331,12 +304,6 @@ public class TabFolderToolbarHandler extends PlatformObject {
 
                // Loop all actions and add them to the menu manager
                for (AbstractTerminalAction action : toolbarActions) {
-                       /* Tizen */
-                       // Skip copy, paste action
-                       if(action instanceof TerminalActionCopy || action instanceof TerminalActionPaste) {
-                               continue;
-                       }
-                       /* ===== */
                        // Add a separator before the clear all action or if the action is a separator
                        if (action instanceof TabScrollLockAction
                                || (action instanceof AbstractAction && ((AbstractAction)action).isSeparator())) {
@@ -347,16 +314,16 @@ public class TabFolderToolbarHandler extends PlatformObject {
                                newTerminalAction = (NewTerminalViewAction)action;
                                continue;
                        }
+
                        // Add the action itself
                        manager.insertAfter("anchor", action); //$NON-NLS-1$
                }
                // now add to the end
-               /* Tizen */
-               manager.add(new Separator());
-               /* ===== */
+
                if (newTerminalAction != null){
                        manager.add(newTerminalAction);
                }
+
        }
 
        /**
diff --git a/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view.png b/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view.png
new file mode 100644 (file)
index 0000000..ab822a9
Binary files /dev/null and b/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view.png differ
diff --git a/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view_sel.png b/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view_sel.png
new file mode 100644 (file)
index 0000000..6575060
Binary files /dev/null and b/rt-ide/tizen.rt.product.plugin/icons/terminal/tab_terminal_view_sel.png differ
index 8993ac9..207e9ec 100644 (file)
             </command>
          </toolbar>
       </menuContribution>
+      <!-- for terminal start-->
+      <menuContribution locationURI="toolbar:org.tizen.rt.ide.view.RtTerminalsView">
+         <command
+               commandId="org.eclipse.tm.terminal.view.ui.command.launchToolbar"
+               icon="icons/terminal/view_menu_open_t_nor.png"
+               id="org.eclipse.tm.terminal.view.ui.commands.launchToolbarTerminalsView"
+               label="%command.launch.label"
+               style="push"
+               tooltip="%command.launch.tooltip">
+         </command>
+         <command
+               commandId="org.eclipse.tm.terminal.view.ui.command.disconnect"
+               icon="icons/terminal/view_menu_disconnect_terminal_nor.png"
+               id="org.eclipse.tm.terminal.view.ui.commands.disconnect"
+               label="%command.disconnect.label"
+               style="push"
+               tooltip="%command.disconnect.tooltip">
+         </command>
+      </menuContribution>
+      <!-- for terminal end-->
+
    </extension>
    <extension
          id="product"
                id="org.eclipse.tm.terminal.view.ui.commands.launchToolbar">
          </hiddenToolBarItem>
          <view
-               id="org.eclipse.tm.terminal.view.ui.TerminalsView"
+               id="org.tizen.rt.ide.view.RtTerminalsView"
                minimized="false"
                relationship="stack"
                relative="org.eclipse.cdt.debug.ui.executablesView">
             name="Project Explorer"
             restorable="true">
       </view>
+      <!-- For Wrapping TerminalsView with RtTerminalsView. start -->
+      <view
+            class="org.tizen.rt.ide.views.RtTerminalsViewEx"
+            id="org.tizen.rt.ide.view.RtTerminalsView"
+            icon="icons/terminal/tab_terminal_view.png"
+            name="Terminal"
+            restorable="true">
+      </view>
+      <!-- For Wrapping TerminalsView with RtTerminalsView. end -->
    </extension>
   <!-- Defined Activity -->
   <extension point="org.eclipse.ui.activities">
index cca4a12..97905ed 100644 (file)
@@ -67,7 +67,7 @@ public class TizenRTPerspective implements IPerspectiveFactory {
         IFolderLayout bottom = factory.createFolder("bottomRight", //$NON-NLS-1$
                 IPageLayout.BOTTOM, 0.75f, factory.getEditorArea());
         bottom.addView(IConsoleConstants.ID_CONSOLE_VIEW);
-        bottom.addView("org.eclipse.tm.terminal.view.ui.TerminalsView"); //$NON-NLS-1$
+        bottom.addView("org.tizen.rt.ide.view.RtTerminalsView"); //$NON-NLS-1$
         bottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
 
         IFolderLayout topRight = factory.createFolder("topRight", //$NON-NLS-1$
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/RtTerminalsViewEx.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/RtTerminalsViewEx.java
new file mode 100644 (file)
index 0000000..3e1ee66
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+*  TabFolderToolbarHandlerEx
+*
+* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Jaemin Kim <jm.jemin.kim@samsung.com>
+* HyeongSeok Heo <harry.heo@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+package org.tizen.rt.ide.views;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
+import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler;
+import org.eclipse.tm.terminal.view.ui.view.TerminalsView;
+
+public class RtTerminalsViewEx extends TerminalsView {
+
+    public RtTerminalsViewEx() {
+        super();
+    }
+
+    @Override
+    protected TabFolderToolbarHandler doCreateTabFolderToolbarHandler(ITerminalsView parentView) {
+        Assert.isNotNull(parentView);
+        return new TabFolderToolbarHandlerEx(parentView);
+    }
+
+}
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/TabFolderToolbarHandlerEx.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/views/TabFolderToolbarHandlerEx.java
new file mode 100644 (file)
index 0000000..c268996
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+*  TabFolderToolbarHandlerEx
+*
+* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Jaemin Kim <jm.jemin.kim@samsung.com>
+* HyeongSeok Heo <harry.heo@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.rt.ide.views;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
+import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction;
+import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy;
+import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste;
+import org.eclipse.tm.terminal.view.ui.actions.AbstractAction;
+import org.eclipse.tm.terminal.view.ui.actions.NewTerminalViewAction;
+import org.eclipse.tm.terminal.view.ui.actions.TabScrollLockAction;
+import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView;
+import org.eclipse.tm.terminal.view.ui.tabs.TabFolderToolbarHandler;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+
+public class TabFolderToolbarHandlerEx extends TabFolderToolbarHandler {
+
+    public TabFolderToolbarHandlerEx(ITerminalsView parentView) {
+        super(parentView);
+    }
+
+    @Override
+    public void initialize() {
+        super.initialize();
+
+        // Fill the menubar
+        IActionBars bars = getParentView().getViewSite().getActionBars();
+        IMenuManager menuManager = bars.getMenuManager();
+        doFillMenubar(menuManager);
+
+    }
+
+    private void doFillMenubar(IMenuManager menuManager) {
+        // we want that at the end
+        AbstractTerminalAction pasteAction = null;
+
+        for (AbstractTerminalAction action : toolbarActions) {
+            // Fill only copy, paste action in menubar
+            if (action instanceof TerminalActionCopy) {
+                menuManager.add(action);
+            } else if (action instanceof TerminalActionPaste) {
+                pasteAction = action;
+            }
+        }
+        // now add to the end
+        if (pasteAction != null) {
+            menuManager.add(pasteAction);
+        }
+    }
+
+    /**
+     * Fill in the context menu content within the given manager.
+     * @param manager The menu manager. Must not be <code>null</code>.
+     */
+    @Override
+    protected void doFillToolbar(IToolBarManager manager) {
+        Assert.isNotNull(manager);
+
+        // Note: For the toolbar, the actions are added from left to right!
+        // So we start with the additions marker here which is the most
+        // left contribution item.
+        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+        manager.add(new Separator("anchor")); //$NON-NLS-1$
+
+        // we want that at the end
+        NewTerminalViewAction newTerminalAction = null;
+
+        // The code that exists to specify the location of savelog.
+        ToggleSaveLogAction toggleSaveLogAction = null;
+
+        // Loop all actions and add them to the menu manager
+        for (AbstractTerminalAction action : toolbarActions) {
+            // Skip copy, paste action
+            if (action instanceof TerminalActionCopy || action instanceof TerminalActionPaste) {
+                continue;
+            }
+            // Add a separator before the clear all action or if the action is a separator
+            if (action instanceof TabScrollLockAction
+                    || (action instanceof AbstractAction && ((AbstractAction) action).isSeparator())) {
+                manager.insertAfter("anchor", new Separator()); //$NON-NLS-1$
+            }
+            // skip new terminal view action for now
+            if (action instanceof NewTerminalViewAction) {
+                newTerminalAction = (NewTerminalViewAction) action;
+                continue;
+            }
+
+            // Add the action itself
+            manager.insertAfter("anchor", action); //$NON-NLS-1$
+        }
+        // now add to the end
+        manager.add(new Separator());
+
+        if (newTerminalAction != null) {
+            manager.add(newTerminalAction);
+        }
+    }
+}