Search in sources :

Example 66 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class SpagicDeployWizard method init.

/*
     * (non-Javadoc) Method declared on IWorkbenchWizard.
     */
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;
    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }
    //$NON-NLS-1$
    setWindowTitle(Messages.getString("SapgicDeployWizard.exporttospagic"));
    //        setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportzip_wiz.png"));//$NON-NLS-1$
    setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(IDEWorkbenchPlugin.IDE_WORKBENCH, //$NON-NLS-1$
    "$nl$/icons/full/wizban/exportzip_wiz.png"));
    setNeedsProgressMonitor(true);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 67 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tesb-studio-se by Talend.

the class JobCamelScriptsExportWizard method init.

public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;
    List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 68 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tesb-studio-se by Talend.

the class CamelDependenciesPanel method moveUp.

private void moveUp() {
    ManifestItem selected = (ManifestItem) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    List input = (List) tableViewer.getInput();
    int index = input.indexOf(selected);
    int size = input.size();
    int targetIndex = index - 1;
    if (targetIndex < 0 || ((ManifestItem) input.get(targetIndex)).isBuiltIn()) {
        targetIndex = size - 1;
    }
    input.remove(selected);
    input.add(targetIndex, selected);
    tableViewer.refresh();
    tableViewer.setSelection(new StructuredSelection(selected));
    tableViewer.getTable().showSelection();
    fireDependenciesChangedListener();
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 69 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project translationstudio8 by heartsome.

the class ConverterCommandTrigger method openDialog.

private static void openDialog(IWorkbenchWindow window, IFile file, String commandId) {
    IWorkbench workbench = window.getWorkbench();
    ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
    Command command = commandService.getCommand(commandId);
    try {
        EvaluationContext context = new EvaluationContext(null, IEvaluationContext.UNDEFINED_VARIABLE);
        context.addVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME, window);
        if (file != null) {
            StructuredSelection selection = new StructuredSelection(file);
            context.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
        }
        command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, context));
    } catch (ExecutionException e) {
        LOGGER.error("", e);
    } catch (NotDefinedException e) {
        LOGGER.error("", e);
    } catch (NotEnabledException e) {
        LOGGER.error("", e);
    } catch (NotHandledException e) {
        LOGGER.error("", e);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) NotHandledException(org.eclipse.core.commands.NotHandledException) Command(org.eclipse.core.commands.Command) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) ExecutionException(org.eclipse.core.commands.ExecutionException) NotEnabledException(org.eclipse.core.commands.NotEnabledException) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 70 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.

the class DeleteSerialAction method run.

/**
	 * Delete the selected serials
	 */
public void run(ISchemaNode[] nodeArray) {
    if (nodeArray == null) {
        LOGGER.error("The nodeArray parameter is a null.");
        return;
    }
    final List<String> serialNameList = new ArrayList<String>();
    final StringBuffer serialNames = new StringBuffer();
    for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
        if (!isSupported(nodeArray[i])) {
            setEnabled(false);
            return;
        }
        ISchemaNode schemaNode = (ISchemaNode) nodeArray[i];
        if (i == 0) {
            serialNames.append(schemaNode.getLabel());
        }
        serialNameList.add(schemaNode.getLabel());
    }
    if (nodeArray.length > 1) {
        serialNames.append(", ...");
    }
    String cfmMsg = Messages.bind(Messages.msgConfirmDelSerial, serialNames.toString(), nodeArray.length);
    boolean isDelete = CommonUITool.openConfirmBox(getShell(), cfmMsg);
    if (!isDelete) {
        return;
    }
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            String taskName = Messages.bind(Messages.delSerialTaskName, serialNames.toString());
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                if (task instanceof DeleteSerialTask) {
                    DeleteSerialTask deleteSerialTask = (DeleteSerialTask) task;
                    String[] serialNames = new String[serialNameList.size()];
                    deleteSerialTask.deleteSerial(serialNameList.toArray(serialNames));
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            return true;
        }
    };
    ISchemaNode schemaNode = (ISchemaNode) nodeArray[0];
    CubridDatabase database = schemaNode.getDatabase();
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    DeleteSerialTask deleteSerialTask = new DeleteSerialTask(databaseInfo);
    taskExcutor.addTask(deleteSerialTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    ICubridNode parent = schemaNode.getParent();
    if (provider instanceof TreeViewer) {
        TreeViewer viewer = (TreeViewer) provider;
        for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
            parent.removeChild((ICubridNode) nodeArray[i]);
        }
        viewer.remove(parent, nodeArray);
        viewer.setSelection(new StructuredSelection(parent), true);
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(viewer, parent);
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DeleteSerialTask(com.cubrid.cubridmanager.core.cubrid.serial.task.DeleteSerialTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)181 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)90 ArrayList (java.util.ArrayList)48 ISelection (org.eclipse.jface.viewers.ISelection)37 List (java.util.List)35 TreeViewer (org.eclipse.jface.viewers.TreeViewer)22 IFile (org.eclipse.core.resources.IFile)19 GridData (org.eclipse.swt.layout.GridData)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)16 Composite (org.eclipse.swt.widgets.Composite)16 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)15 Label (org.eclipse.swt.widgets.Label)14 Shell (org.eclipse.swt.widgets.Shell)14 IViewPart (org.eclipse.ui.IViewPart)14 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)14 IEditorPart (org.eclipse.ui.IEditorPart)13 GridLayout (org.eclipse.swt.layout.GridLayout)12