import java.io.IOException;
import java.util.List;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.PlatformUI;
import org.tizen.rt.ide.RtosCommandManager;
-import org.tizen.rt.ide.util.WorkspaceUtil;
+import org.tizen.rt.ide.util.ResourceUtil;
/**
* DeviceGuideDialogPage Select Emulator Wizard Feature
public void widgetSelected(SelectionEvent arg0) {
try {
Runtime.getRuntime().exec(new String[] { "gnome-terminal", "--command", "make menuconfig" }, null,
- new File(WorkspaceUtil.getCurrentProjectPath() + File.separator + "os"));
+ new File(ResourceUtil.getCurrentProject().getLocation().toString() + File.separator + "os"));
} catch (IOException e) {
- e.printStackTrace();
+ MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Could not execute kconfig");
+ return;
}
}
});
+/*
+* Common
+*
+* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* jm.jemin.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.util;
import org.eclipse.core.resources.IProject;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+/**
+ * Workspace Resource Utility Functions
+ * @author gyeongmin.ju{@literal <gyeongmin.ju>} (S-Core)
+ */
public class ResourceUtil {
public static IResource getCurrentResource() {
IResource res = null;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IEditorPart editorPart = window.getActivePage().getActiveEditor();
-
- if (editorPart != null) {
- IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput();
- res = input.getFile();
- } else {
- ISelectionService selectionService = window.getSelectionService();
- if (selectionService != null) {
- ISelection selection = selectionService.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement instanceof IResource) {
- res = (IResource) firstElement;
- }
+
+ ISelectionService selectionService = window.getSelectionService();
+ if (selectionService != null) {
+ ISelection selection = selectionService.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ if (firstElement instanceof IResource) {
+ res = (IResource) firstElement;
}
}
}
+ if (res == null) {
+ IEditorPart editorPart = window.getActivePage().getActiveEditor();
+
+ if (editorPart != null) {
+ IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput();
+ res = input.getFile();
+ }
+ }
+
return res;
}
+++ /dev/null
-/**
- * Common
- *
- * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Daeryong Park <bdragon.park@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.util;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-public class WorkspaceUtil {
-
- public static String getCurrentProjectPath() {
- String projPath = null;
-
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IEditorPart editorPart = window.getActivePage().getActiveEditor();
- if (editorPart != null) {
- IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput();
- IFile file = input.getFile();
- IProject activeProject = file.getProject();
- projPath = activeProject.getLocation().toString();
- } else {
- ISelectionService selectionService = window.getSelectionService();
- if (selectionService != null) {
- ISelection selection = selectionService.getSelection();
- if (selection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement instanceof IResource) {
- IProject activeProject = ((IResource) firstElement).getProject();
- projPath = activeProject.getLocation().toString();
- }
- }
- }
- }
-
- return projPath;
- }
-
-}