Search in sources :

Example 41 with StructuredSelection

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

the class ClipboardActionHandler method getCommand.

@Override
public ICommand getCommand(IGlobalActionContext cntxt) {
    IWorkbenchPart part = cntxt.getActivePart();
    if (!(part instanceof IDiagramWorkbenchPart)) {
        return null;
    }
    IDiagramWorkbenchPart workbenchPart = (IDiagramWorkbenchPart) part;
    DiagramEditPart diagramEditPart = workbenchPart.getDiagramEditPart();
    ICommand command = null;
    String actionId = cntxt.getActionId();
    if (actionId.equals(GlobalActionId.COPY)) {
        command = getCopyCommand(cntxt, workbenchPart, false);
        transfer(cntxt.getSelection());
        isCut = false;
        older = workbenchPart;
        orginalCopyFrom = workbenchPart;
        clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
    } else if (actionId.equals(GlobalActionId.CUT) && cntxt.getSelection() != null) {
        saveCut(cntxt.getSelection());
        command = getCutCommand(cntxt, workbenchPart);
        transfer(cntxt.getSelection());
        isCut = true;
        older = workbenchPart;
        clonedSourceProcessItemsList = new ArrayList<BusinessItem>(((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement()).getBusinessItems());
    } else if (actionId.equals(GlobalActionId.SAVE)) {
        if (workbenchPart instanceof IEditorPart) {
            IEditorPart editorPart = (IEditorPart) workbenchPart;
            if (editorPart.isDirty()) {
                IWorkbenchPage page = editorPart.getSite().getPage();
                page.saveEditor(editorPart, false);
            }
        }
    }
    if (actionId.equals(GlobalActionId.PASTE)) {
        // diagramPart.getDiagramGraphicalViewer().setSelection(new
        // StructuredSelection(diagramPart.getDiagramEditPart()));
        PasteViewRequest pasteReq = createPasteViewRequest();
        CommandStack cs = workbenchPart.getDiagramEditDomain().getDiagramCommandStack();
        IStructuredSelection selection = (IStructuredSelection) cntxt.getSelection();
        if (!(selection.getFirstElement() instanceof BusinessProcessEditPart)) {
            selection = new StructuredSelection(workbenchPart.getDiagramEditPart());
        }
        Object[] objects = selection.toArray();
        Collection returnValues = null;
        if (objects.length == 1) {
            Command paste = ((EditPart) objects[0]).getCommand(pasteReq);
            if (paste != null) {
                cs.execute(paste);
                workbenchPart.getDiagramEditPart().getFigure().invalidate();
                workbenchPart.getDiagramEditPart().getFigure().validate();
                returnValues = DiagramCommandStack.getReturnValues(paste);
            // selectAddedObject(diagramPart.getDiagramGraphicalViewer(), returnValues);
            }
        }
        Object elements = TemplateTransfer.getInstance().getObject();
        if (elements instanceof List) {
            List<BusinessItem> list = (List<BusinessItem>) elements;
            boolean inEditors = false;
            if (older != workbenchPart) {
                inEditors = true;
            } else if (!this.isCut && orginalCopyFrom != workbenchPart) {
                // bug 16065 fixed, by xtan. to resolve the copy(A)/parse(B)/parse(B)/parse(B)... problem.
                inEditors = true;
            }
            // always keep the last one as the current selection.
            older = workbenchPart;
            GmfPastCommand pastBusiness = new GmfPastCommand((BusinessProcess) ((Diagram) diagramEditPart.getModel()).getElement(), list, diagramEditPart, this.cutItemIds, this.isCut | inEditors);
            pastBusiness.setClonedSourceProcessItemsList(clonedSourceProcessItemsList);
            try {
                pastBusiness.execute(null, null);
            } catch (ExecutionException e) {
                ExceptionHandler.process(e);
            }
        }
        if (returnValues != null) {
            selectAddedObject(workbenchPart.getDiagramGraphicalViewer(), returnValues);
        }
        return null;
    }
    return command;
}
Also used : PasteViewRequest(org.eclipse.gmf.runtime.diagram.ui.requests.PasteViewRequest) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) ArrayList(java.util.ArrayList) List(java.util.List) ExecutionException(org.eclipse.core.commands.ExecutionException) GmfPastCommand(org.talend.designer.business.diagram.custom.commands.GmfPastCommand) DiagramCommandStack(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack) CommandStack(org.eclipse.gef.commands.CommandStack) IDiagramWorkbenchPart(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) BusinessProcessEditPart(org.talend.designer.business.model.business.diagram.edit.parts.BusinessProcessEditPart) EditPart(org.eclipse.gef.EditPart) IEditorPart(org.eclipse.ui.IEditorPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) GmfPastCommand(org.talend.designer.business.diagram.custom.commands.GmfPastCommand) Command(org.eclipse.gef.commands.Command) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 42 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 43 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)

Example 44 with StructuredSelection

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

the class DropTriggerAction method run.

public void run(ISchemaNode[] nodeArray) {
    // FIXME move this logic to core module
    if (nodeArray == null) {
        LOGGER.error("The nodeArray is a null.");
        return;
    }
    List<String> triggerNameList = new ArrayList<String>();
    StringBuffer bf = new StringBuffer();
    for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
        DefaultSchemaNode trigger = (DefaultSchemaNode) nodeArray[i];
        triggerNameList.add(trigger.getName());
        if (i == 0) {
            bf.append(trigger.getName());
        }
    }
    if (nodeArray.length > 1) {
        bf.append(", ...");
    }
    String cfmMsg = Messages.bind(Messages.dropTriggerWarnMSG1, nodeArray.length, bf.toString());
    boolean ret = CommonUITool.openConfirmBox(cfmMsg);
    if (!ret) {
        return;
    }
    ISchemaNode triggerNode = (ISchemaNode) nodeArray[0];
    CommonSQLExcuterTask task = new CommonSQLExcuterTask(triggerNode.getDatabase().getDatabaseInfo());
    for (String triggerName : triggerNameList) {
        String sql = "DROP TRIGGER " + QuerySyntax.escapeKeyword(triggerName);
        task.addSqls(sql);
    }
    String taskName = Messages.bind(Messages.dropTriggerTaskName, bf.toString());
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    String title = com.cubrid.common.ui.common.Messages.titleSuccess;
    String msg = Messages.dropTriggerSuccessMsg;
    CommonUITool.openInformationBox(title, msg);
    ISelectionProvider provider = this.getSelectionProvider();
    ICubridNode parent = triggerNode.getParent();
    if (provider instanceof TreeViewer) {
        TreeViewer viewer = (TreeViewer) provider;
        for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
            parent.removeChild((ISchemaNode) nodeArray[i]);
        }
        viewer.remove(parent, nodeArray);
        viewer.setSelection(new StructuredSelection(parent), true);
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(viewer, parent);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CommonSQLExcuterTask(com.cubrid.cubridmanager.core.common.task.CommonSQLExcuterTask) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 45 with StructuredSelection

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

the class EditVirtualTableDialog method createFkIndexTabItem.

/**
	 * Create foreign key/Index tab item.
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createFkIndexTabItem(final TabFolder tabFolder) {
    final TabItem foreignKeyTabItem = new TabItem(tabFolder, SWT.NONE);
    foreignKeyTabItem.setText(Messages.infoIndexesTab);
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    composite.setLayout(gridLayout);
    foreignKeyTabItem.setControl(composite);
    // create the fk table viewer
    final Label fkLabel = new Label(composite, SWT.NONE);
    fkLabel.setText(Messages.lblFK);
    fkTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    fkTable = fkTableView.getTable();
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    fkTable.setLayoutData(gdFkTable);
    fkTable.setLinesVisible(true);
    fkTable.setHeaderVisible(true);
    TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnFK);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(119);
    tblCol.setText(Messages.tblColumnColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(93);
    tblCol.setText(Messages.tblColumnForeignTable);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(143);
    tblCol.setText(Messages.tblColumnForeignColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(84);
    tblCol.setText(Messages.tblColumnUpdateRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(86);
    tblCol.setText(Messages.tblColumnDeleteRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnCacheColumn);
    FKTableViewerContentProvider fkContentProvider = new FKTableViewerContentProvider();
    FKTableViewerLabelProvider fkLabelProvider = new FKTableViewerLabelProvider(database.getDatabaseInfo(), erSchema);
    fkTableView.setContentProvider(fkContentProvider);
    fkTableView.setLabelProvider(fkLabelProvider);
    fkTableView.setInput(getNewSchemaInfo());
    final Composite fkBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    fkBtnComposite.setLayoutData(gdBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    fkBtnComposite.setLayout(gridLayout);
    final GridData gdFKBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addFKBTN = new Button(fkBtnComposite, SWT.NONE);
    addFKBTN.setLayoutData(gdFKBTN);
    addFKBTN.setText(Messages.btnAddFk);
    addFKBTN.addSelectionListener(new AddFkBtnListenerOnFkIndexTab());
    final Button editFKBTN = new Button(fkBtnComposite, SWT.NONE);
    editFKBTN.setLayoutData(gdFKBTN);
    editFKBTN.setEnabled(false);
    editFKBTN.setText(Messages.btnEditFk);
    editFKBTN.addSelectionListener(new EditFkBtnListenerOnFkIndexTab());
    final Button deleteFKBTN = new Button(fkBtnComposite, SWT.NONE);
    deleteFKBTN.setLayoutData(gdFKBTN);
    deleteFKBTN.setEnabled(false);
    deleteFKBTN.setText(Messages.btnDelFk);
    deleteFKBTN.addSelectionListener(new DelFkBtnListenerOnFkIndexTab());
    fkTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            SchemaInfo newSchemaInfo = getNewSchemaInfo();
            if (database == null || database.getDatabaseInfo() == null || newSchemaInfo == null) {
                return;
            }
            TableItem[] items = fkTable.getSelection();
            if (items == null || items.length == 0) {
                deleteFKBTN.setEnabled(false);
                editFKBTN.setEnabled(false);
            } else {
                deleteFKBTN.setEnabled(true);
                editFKBTN.setEnabled(items.length == 1);
                for (TableItem item : items) {
                    String fkName = item.getText(0);
                    List<SchemaInfo> superList = SuperClassUtil.getSuperClasses(database.getDatabaseInfo(), newSchemaInfo.getSuperClasses());
                    if (newSchemaInfo.isInSuperClasses(superList, fkName)) {
                        deleteFKBTN.setEnabled(false);
                        editFKBTN.setEnabled(false);
                    }
                }
            }
        }
    });
    // create index table view
    final Label indexLabel = new Label(composite, SWT.NONE);
    indexLabel.setText(Messages.lblIndexes);
    indexTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    indexTable = indexTableView.getTable();
    indexTable.setLinesVisible(true);
    indexTable.setHeaderVisible(true);
    final GridData gdIndexTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    indexTable.setLayoutData(gdIndexTable);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(150);
    tblCol.setText(Messages.tblColumnIndexName);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(78);
    tblCol.setText(Messages.tblColumnIndexType);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(218);
    tblCol.setText(Messages.tblColumnOnColumns);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(282);
    tblCol.setText(Messages.tblColumnIndexRule);
    IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
    IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
    indexTableView.setContentProvider(indexContentProvider);
    indexTableView.setLabelProvider(indexLabelProvider);
    indexTableView.setInput(getNewSchemaInfo());
    indexTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection selected = (StructuredSelection) event.getSelection();
            if (selected == null) {
                return;
            }
            Constraint constraint = (Constraint) selected.getFirstElement();
            openEditIndexDialog(constraint);
        }
    });
    final Composite indexBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdIndexBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    indexBtnComposite.setLayoutData(gdIndexBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    indexBtnComposite.setLayout(gridLayout);
    final GridData gdIndexBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    addIndexBTN.setLayoutData(gdIndexBTN);
    addIndexBTN.setText(Messages.btnAddIndex);
    addIndexBTN.addSelectionListener(new AddIndexBtnListenerOnFkIndexTab());
    final Button editIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    editIndexBTN.setLayoutData(gdIndexBTN);
    editIndexBTN.setEnabled(false);
    editIndexBTN.setText(Messages.btnEditIndex);
    editIndexBTN.addSelectionListener(new EditIndexBtnListenerOnFkIndexTab());
    final Button deleteIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    deleteIndexBTN.setLayoutData(gdIndexBTN);
    deleteIndexBTN.setEnabled(false);
    deleteIndexBTN.setText(Messages.btnDelIndex);
    deleteIndexBTN.addSelectionListener(new DelIndexBtnListenerOnFkIndexTab());
    indexTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem[] items = indexTable.getSelection();
            if (items == null || items.length == 0) {
                deleteIndexBTN.setEnabled(false);
                editIndexBTN.setEnabled(false);
            } else {
                deleteIndexBTN.setEnabled(true);
                editIndexBTN.setEnabled(items.length == 1);
            }
        }
    });
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) FKTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IndexTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerContentProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) IndexTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) FKTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1376 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)782 ArrayList (java.util.ArrayList)212 ISelection (org.eclipse.jface.viewers.ISelection)177 Composite (org.eclipse.swt.widgets.Composite)167 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)133 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)128 GridData (org.eclipse.swt.layout.GridData)112 List (java.util.List)93 IFile (org.eclipse.core.resources.IFile)92 GridLayout (org.eclipse.swt.layout.GridLayout)87 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 Label (org.eclipse.swt.widgets.Label)79 TreeViewer (org.eclipse.jface.viewers.TreeViewer)78 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)68 EObject (org.eclipse.emf.ecore.EObject)67 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)66 TableViewer (org.eclipse.jface.viewers.TableViewer)64 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)61 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)60