import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
} catch (PartInitException e) {
DALog.printLog("OpenEditManager - openEditor - PartInitException");
}
-
+
return page.getActiveEditor();
}
return _editor;
}
- public void run(){
+ public void run(){
try
{
int offset;
+
initEditor(this.filepath);
+
if(this.fileline > 0)
{
offset = _document.getLineOffset(this.fileline - 1);
offset = 0;
}
getEditor().setHighlightRange(offset, 0, true); //move cursor
-
-// FocusManager fm = new FocusManager();
-// fm.start();
- Display.getCurrent().syncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- if (null == shell.getDisplay().getActiveShell()) {
- shell.open();
- shell.setFullScreen(true);
- shell.setFullScreen(false);
- shell.setFocus();
- shell.forceActive();
- }
- }
- });
+
+ String os = System.getProperty("os.name").toLowerCase();
+ if(os.indexOf("mac") >= 0){
+ forceActiveOnMac();
+ }else if(os.indexOf("linux") >= 0){
+ //forActiveOnLinux();
+ FocusManager fm = new FocusManager();
+ fm.start();
+ }
}
catch (IOException e)
- {
+ {
DALog.printLog("OpenEditManager - run - IOException");
}
catch (BadLocationException e)
- {
+ {
DALog.printLog("OpenEditManager - run - BadLocationException");
}
}
+ public void forActiveOnLinux() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFullScreen(true);
+ shell.setFullScreen(false);
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnMac() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFocus();
+ shell.setActive();
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Jungwook Ryu <jungwook.ryu@samsung.com>
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Juyoung Kim <j0.kim@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.dynamicanalysis.ide.eplugin.communication;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.tizen.dynamicanalysis.ide.eplugin.DALog;
+import org.eclipse.swt.internal.win32.*;
+
+public class OpenEditManager implements Runnable
+{
+ private ITextEditor _editor;
+ private IDocument _document;
+ private String filepath;
+ private int fileline;
+
+ public OpenEditManager(String path, int line)
+ {
+ this.filepath = path;
+ this.fileline = line;
+ }
+
+ private void initEditor( final String path ) throws IOException
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile ifile = root.getFile(new Path(path));
+ IEditorPart part = null;
+
+ if (!ifile.exists())
+ {
+ File targetfile = new File(path);
+ if(targetfile.exists() && targetfile.isFile())
+ {
+ IFileStore filestore = EFS.getLocalFileSystem().getStore(targetfile.toURI());
+ part = openEditor(filestore);
+ }
+ else
+ {
+ throw new IOException("Source file (" + path + ") is not found.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else
+ {
+ part = openEditor(ifile);
+ }
+
+ if(part != null && (part instanceof ITextEditor))
+ {
+ _editor = (ITextEditor)part;
+ IDocumentProvider provider = _editor.getDocumentProvider();
+ _document = provider.getDocument(_editor.getEditorInput());
+
+ }
+ }
+
+ private IEditorPart openEditor(final IFile ifile) {
+ // editor open
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, ifile);
+ } catch (PartInitException e) {
+ DALog.printLog("OpenEditManager - openEditor - PartInitException");
+ }
+
+ return page.getActiveEditor();
+ }
+
+ private IEditorPart openEditor(final IFileStore ifilestr) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditorOnFileStore(page, ifilestr);
+ } catch (PartInitException e) {
+ DALog.printLog("OpenEditManager - openEditor - PartInitException");
+ }
+
+ return page.getActiveEditor();
+ }
+
+ private ITextEditor getEditor()
+ {
+ return _editor;
+ }
+
+ public void run(){
+ try
+ {
+ int offset;
+
+ initEditor(this.filepath);
+
+ if(this.fileline > 0)
+ {
+ offset = _document.getLineOffset(this.fileline - 1);
+ }
+ else
+ {
+ offset = 0;
+ }
+ getEditor().setHighlightRange(offset, 0, true); //move cursor
+
+ String os = System.getProperty("os.name").toLowerCase();
+ if(os.indexOf("win") >= 0) {
+ forceActiveOnWindows();
+ }else if(os.indexOf("mac") >= 0){
+ forceActiveOnMac();
+ }else if(os.indexOf("linux") >= 0){
+ //forActiveOnLinux();
+ FocusManager fm = new FocusManager();
+ fm.start();
+ }
+ }
+ catch (IOException e)
+ {
+ DALog.printLog("OpenEditManager - run - IOException");
+ }
+ catch (BadLocationException e)
+ {
+ DALog.printLog("OpenEditManager - run - BadLocationException");
+ }
+ }
+
+ public void forActiveOnLinux() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFullScreen(true);
+ shell.setFullScreen(false);
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnMac() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFocus();
+ shell.setActive();
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnWindows() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+
+ int hFrom = OS.GetForegroundWindow();
+
+ if (hFrom <= 0) {
+ OS.SetForegroundWindow(shell.handle);
+ return;
+ }
+
+ int pid = OS.GetWindowThreadProcessId(hFrom, null);
+ int threadid = OS.GetWindowThreadProcessId(shell.handle, null);
+
+ if (threadid == pid) {
+ OS.SetForegroundWindow(shell.handle);
+ return;
+ }
+
+ if (pid > 0) {
+ if (!OS.AttachThreadInput(threadid, pid, true)) {
+ return;
+ }
+ OS.SetForegroundWindow(shell.handle);
+ OS.AttachThreadInput(threadid, pid, false);
+ }
+
+ OS.BringWindowToTop(shell.handle);
+ OS.UpdateWindow(shell.handle);
+ OS.SetActiveWindow(shell.handle);
+
+ if(OS.IsIconic(shell.handle)) {
+ // OS.SW_RESTORE : If the window is minimized or maximized, the system
+ // restores it to its original size and position.
+ OS.ShowWindow(shell.handle, OS.SW_RESTORE);
+ }
+
+ }
+}
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
-
import org.tizen.dynamicanalysis.ide.eplugin.DALog;
public class OpenEditManager implements Runnable
} catch (PartInitException e) {
DALog.printLog("OpenEditManager - openEditor - PartInitException");
}
-
+
return page.getActiveEditor();
}
return _editor;
}
- public void run(){
+ public void run(){
try
{
int offset;
+
initEditor(this.filepath);
+
if(this.fileline > 0)
{
offset = _document.getLineOffset(this.fileline - 1);
offset = 0;
}
getEditor().setHighlightRange(offset, 0, true); //move cursor
-
- FocusManager fm = new FocusManager();
- fm.start();
+
+ String os = System.getProperty("os.name").toLowerCase();
+ if(os.indexOf("mac") >= 0){
+ forceActiveOnMac();
+ }else if(os.indexOf("linux") >= 0){
+ //forActiveOnLinux();
+ FocusManager fm = new FocusManager();
+ fm.start();
+ }
}
catch (IOException e)
- {
+ {
DALog.printLog("OpenEditManager - run - IOException");
}
catch (BadLocationException e)
- {
+ {
DALog.printLog("OpenEditManager - run - BadLocationException");
}
}
+ public void forActiveOnLinux() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFullScreen(true);
+ shell.setFullScreen(false);
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnMac() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFocus();
+ shell.setActive();
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
}
--- /dev/null
+/*
+ * Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Jungwook Ryu <jungwook.ryu@samsung.com>
+ * Jaewon Lim <jaewon81.lim@samsung.com>
+ * Juyoung Kim <j0.kim@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.dynamicanalysis.ide.eplugin.communication;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.tizen.dynamicanalysis.ide.eplugin.DALog;
+import org.eclipse.swt.internal.win32.*;
+
+public class OpenEditManager implements Runnable
+{
+ private ITextEditor _editor;
+ private IDocument _document;
+ private String filepath;
+ private int fileline;
+
+ public OpenEditManager(String path, int line)
+ {
+ this.filepath = path;
+ this.fileline = line;
+ }
+
+ private void initEditor( final String path ) throws IOException
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile ifile = root.getFile(new Path(path));
+ IEditorPart part = null;
+
+ if (!ifile.exists())
+ {
+ File targetfile = new File(path);
+ if(targetfile.exists() && targetfile.isFile())
+ {
+ IFileStore filestore = EFS.getLocalFileSystem().getStore(targetfile.toURI());
+ part = openEditor(filestore);
+ }
+ else
+ {
+ throw new IOException("Source file (" + path + ") is not found.");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else
+ {
+ part = openEditor(ifile);
+ }
+
+ if(part != null && (part instanceof ITextEditor))
+ {
+ _editor = (ITextEditor)part;
+ IDocumentProvider provider = _editor.getDocumentProvider();
+ _document = provider.getDocument(_editor.getEditorInput());
+
+ }
+ }
+
+ private IEditorPart openEditor(final IFile ifile) {
+ // editor open
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, ifile);
+ } catch (PartInitException e) {
+ DALog.printLog("OpenEditManager - openEditor - PartInitException");
+ }
+
+ return page.getActiveEditor();
+ }
+
+ private IEditorPart openEditor(final IFileStore ifilestr) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditorOnFileStore(page, ifilestr);
+ } catch (PartInitException e) {
+ DALog.printLog("OpenEditManager - openEditor - PartInitException");
+ }
+
+ return page.getActiveEditor();
+ }
+
+ private ITextEditor getEditor()
+ {
+ return _editor;
+ }
+
+ public void run(){
+ try
+ {
+ int offset;
+
+ initEditor(this.filepath);
+
+ if(this.fileline > 0)
+ {
+ offset = _document.getLineOffset(this.fileline - 1);
+ }
+ else
+ {
+ offset = 0;
+ }
+ getEditor().setHighlightRange(offset, 0, true); //move cursor
+
+ String os = System.getProperty("os.name").toLowerCase();
+ if(os.indexOf("win") >= 0) {
+ forceActiveOnWindows();
+ }else if(os.indexOf("mac") >= 0){
+ forceActiveOnMac();
+ }else if(os.indexOf("linux") >= 0){
+ //forActiveOnLinux();
+ FocusManager fm = new FocusManager();
+ fm.start();
+ }
+ }
+ catch (IOException e)
+ {
+ DALog.printLog("OpenEditManager - run - IOException");
+ }
+ catch (BadLocationException e)
+ {
+ DALog.printLog("OpenEditManager - run - BadLocationException");
+ }
+ }
+
+ public void forActiveOnLinux() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFullScreen(true);
+ shell.setFullScreen(false);
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnMac() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ shell.moveAbove(null);
+ shell.setVisible(true);
+ shell.setFocus();
+ shell.setActive();
+ shell.open();
+ shell.forceFocus();
+ shell.forceActive();
+ }
+ });
+ }
+
+ public void forceActiveOnWindows() {
+ final Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+
+ int hFrom = OS.GetForegroundWindow();
+
+ if (hFrom <= 0) {
+ OS.SetForegroundWindow(shell.handle);
+ return;
+ }
+
+ int pid = OS.GetWindowThreadProcessId(hFrom, null);
+ int threadid = OS.GetWindowThreadProcessId(shell.handle, null);
+
+ if (threadid == pid) {
+ OS.SetForegroundWindow(shell.handle);
+ return;
+ }
+
+ if (pid > 0) {
+ if (!OS.AttachThreadInput(threadid, pid, true)) {
+ return;
+ }
+ OS.SetForegroundWindow(shell.handle);
+ OS.AttachThreadInput(threadid, pid, false);
+ }
+
+ OS.BringWindowToTop(shell.handle);
+ OS.UpdateWindow(shell.handle);
+ OS.SetActiveWindow(shell.handle);
+
+ if(OS.IsIconic(shell.handle)) {
+ // OS.SW_RESTORE : If the window is minimized or maximized, the system
+ // restores it to its original size and position.
+ OS.ShowWindow(shell.handle, OS.SW_RESTORE);
+ }
+
+ }
+}
cp -r $temp_dir/* $build_path/plugins
rm -rf $temp_dir
+ src_dir=""
if [ "x${package_name}" = "xdynamic-analysis-ide-eplugin" ]
then
rm -rf $build_path/plugins/org.tizen.dynamicanalysis.ide.native.eplugin
+ src_dir="${build_path}/plugins/org.tizen.dynamicanalysis.ide.eplugin/src"
elif [ "x${package_name}" = "xdynamic-analysis-ide-native-eplugin" ]
then
rm -rf $build_path/plugins/org.tizen.dynamicanalysis.ide.eplugin
+ src_dir="${build_path}/plugins/org.tizen.dynamicanalysis.ide.native.eplugin/src"
fi
+
+ ## Select OpenEditManager.java
+ case ${TARGET_OS} in
+ ubuntu-32|ubuntu-64|macos-64)
+ mv $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java_Linux $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java
+ rm $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java_Window
+ ;;
+ windows-32|windows-64)
+ mv $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java_Window $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java
+ rm $src_dir/org/tizen/dynamicanalysis/ide/eplugin/communication/OpenEditManager.java_Linux
+ ;;
+ *)
+ echo "${TARGET_OS} is not support yet."
+ ;;
+ esac
}
__copy_dependency_plugins()