From 19e68b5fdf7b8c82ca79d4b32ec00a8af0d677a8 Mon Sep 17 00:00:00 2001 From: JaeMin Kim Date: Thu, 18 May 2017 18:20:31 +0900 Subject: [PATCH] TERMINAL: Open the logged file at the end of logging. 1. Open the logged file at the end of logging. 2. Modify the toolip text -> Toggle Session logging 3. ViewName modify TerminalEx -> Terminal Change-Id: I3ac7bdf2f21a4c494bf0055c430ed3565fbf0ad3 Signed-off-by: JaeMin Kim --- .../OSGI-INF/l10n/bundle.properties | 5 +++ rt-ide/tizen.rt.terminalex.plugin/plugin.xml | 12 +++--- .../rt/ide/terminal/view/ui/nls/Messages.java | 2 + .../ide/terminal/view/ui/nls/Messages.properties | 9 ++-- .../terminal/view/ui/tabs/ToggleSaveLogAction.java | 49 +++++++++++++++++++--- 5 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 rt-ide/tizen.rt.terminalex.plugin/OSGI-INF/l10n/bundle.properties diff --git a/rt-ide/tizen.rt.terminalex.plugin/OSGI-INF/l10n/bundle.properties b/rt-ide/tizen.rt.terminalex.plugin/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000..811713f --- /dev/null +++ b/rt-ide/tizen.rt.terminalex.plugin/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,5 @@ +command.disconnect.label=Disconnect +command.disconnect.tooltip=Disconnect Terminal Connection + +command.launch.label=Open Terminal... +command.launch.tooltip=Open a Terminal \ No newline at end of file diff --git a/rt-ide/tizen.rt.terminalex.plugin/plugin.xml b/rt-ide/tizen.rt.terminalex.plugin/plugin.xml index 826972c..f869855 100644 --- a/rt-ide/tizen.rt.terminalex.plugin/plugin.xml +++ b/rt-ide/tizen.rt.terminalex.plugin/plugin.xml @@ -42,17 +42,17 @@ 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" + label="Open Terminal" style="push" - tooltip="%command.launch.tooltip"> + tooltip="Open a Terminal"> + tooltip="Disconnect Terminal Connection"> @@ -60,14 +60,14 @@ + name="Terminal"> diff --git a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.java b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.java index 86f235b..2f75e65 100644 --- a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.java +++ b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.java @@ -65,4 +65,6 @@ public class Messages extends NLS { public static String TabSaveLogAction_text; public static String TabSaveLogAction_tooltip; + public static String TabSaveLogAction_start_Logging; + public static String TabSaveLogAction_stop_Logging; } diff --git a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.properties b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.properties index 62393ab..1ff1256 100644 --- a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.properties +++ b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/nls/Messages.properties @@ -1,6 +1,7 @@ -TabSaveLogAction_text=SaveLog -TabSaveLogAction_tooltip=SaveLog to file +TabSaveLogAction_text=Session logging +TabSaveLogAction_tooltip=Toggle Session logging + +TabSaveLogAction_start_Logging=Start logging +TabSaveLogAction_stop_Logging=Stop logging -TabSaveLogAction_tooltip_startLogging=Start logging -TabSaveLogAction_tooltip_stopLogging=Stop logging diff --git a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java index 88bdb26..51d66a2 100644 --- a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java +++ b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java @@ -24,10 +24,13 @@ */ package org.tizen.rt.ide.terminal.view.ui.tabs; +import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Path; @@ -36,19 +39,26 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; -import org.eclipse.tm.internal.terminal.control.SaveLogWithHistory; import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; import org.eclipse.tm.terminal.view.ui.interfaces.ITerminalsView; import org.eclipse.tm.terminal.view.ui.tabs.TabFolderManager; import org.eclipse.tm.terminal.view.ui.tabs.ToggleSaveLogHandler; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.FileStoreEditorInput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.tizen.rt.ide.terminal.view.ui.activator.Activator; import org.tizen.rt.ide.terminal.view.ui.interfaces.ImageConsts; import org.tizen.rt.ide.terminal.view.ui.nls.Messages; -import org.tizen.rt.ide.util.ResourceUtil; +import org.tizen.rt.ide.terminal.view.ui.popup.util.ResourceUtil; public class ToggleSaveLogAction extends AbstractTerminalAction { + boolean isCancelDialog = false; private ITerminalsView view = null; + private final Logger logger = LoggerFactory.getLogger(ToggleSaveLogAction.class); /** * Constructor. @@ -73,14 +83,35 @@ public class ToggleSaveLogAction extends AbstractTerminalAction { @Override public void run() { ToggleSaveLogHandler handler = getSaveLogHandler(); - if (handler != null) { if (!handler.hasLogOutputStream()) { handler.setFileName(openFileDialog()); } handler.setSaveLog(!handler.hasLogOutputStream()); } - setChecked(handler != null && handler.hasLogOutputStream()); + + if (handler != null && handler.hasLogOutputStream()) { + setChecked(true); + } else { + setChecked(false); + if(!isCancelDialog){ + openEditor(handler); + } + } + } + + private void openEditor(ToggleSaveLogHandler handler) { + File fileToOpen = handler.getBeforeCloseFile(); + if (fileToOpen.exists() && fileToOpen.isFile()) { + IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI()); + FileStoreEditorInput editorInput = new FileStoreEditorInput(fileStore); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor"); + } catch (PartInitException e) { + logger.error(e.getMessage(), e); + } + } } private String openFileDialog() { @@ -96,8 +127,14 @@ public class ToggleSaveLogAction extends AbstractTerminalAction { // example) /home/user.home/ide/ DefaultPath = System.getProperty("user.dir"); } - - return openFileDialog(DefaultPath, getLogFileName(item.getText())); + String result = openFileDialog(DefaultPath, getLogFileName(item.getText())); + // check if dialog cancel + if(result == null){ + isCancelDialog = true; + }else{ + isCancelDialog = false; + } + return result; } /* -- 2.7.4