List of usage examples for org.eclipse.jface.viewers StructuredSelection size
@Override public int size()
From source file:org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsOpenLdapAction.java
License:Apache License
/** * {@inheritDoc}/*from ww w. j a v a 2s .c o m*/ */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() > 0)) { for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof SchemaWrapper) { selectedSchemas.add(((SchemaWrapper) o).getSchema()); } } } // Instantiates and initializes the wizard ExportSchemasAsOpenLdapWizard wizard = new ExportSchemasAsOpenLdapWizard(); wizard.setSelectedSchemas(selectedSchemas.toArray(new Schema[0])); wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.create(); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasAsXmlAction.java
License:Apache License
/** * {@inheritDoc}//from w ww. j ava 2 s . c o m */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() > 0)) { for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof SchemaWrapper) { selectedSchemas.add(((SchemaWrapper) o).getSchema()); } } } // Instantiates and initializes the wizard ExportSchemasAsXmlWizard wizard = new ExportSchemasAsXmlWizard(); wizard.setSelectedSchemas(selectedSchemas.toArray(new Schema[0])); wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.create(); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.ExportSchemasForADSAction.java
License:Apache License
/** * {@inheritDoc}/*from w w w . j ava 2 s .c o m*/ */ public void run() { List<Schema> selectedSchemas = new ArrayList<Schema>(); // Getting the selection StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() > 0)) { for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof SchemaWrapper) { selectedSchemas.add(((SchemaWrapper) o).getSchema()); } } } // Instantiates and initializes the wizard ExportSchemasForADSWizard wizard = new ExportSchemasForADSWizard(); wizard.setSelectedSchemas(selectedSchemas.toArray(new Schema[0])); wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.create(); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.NewAttributeTypeAction.java
License:Apache License
/** * {@inheritDoc}/* w w w . j av a 2 s. c o m*/ */ public void run() { // Getting the selection Schema selectedSchema = null; int presentation = Activator.getDefault().getPreferenceStore() .getInt(PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION); if (presentation == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT) { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() == 1)) { Object firstElement = selection.getFirstElement(); if (firstElement instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) firstElement).getSchema(); } else if (firstElement instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) firstElement).getParent()).getSchema(); } else if (firstElement instanceof AttributeTypeWrapper) { TreeNode parent = ((AttributeTypeWrapper) firstElement).getParent(); if (parent instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) parent).getParent()).getSchema(); } else if (parent instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) parent).getSchema(); } } else if (firstElement instanceof ObjectClassWrapper) { TreeNode parent = ((ObjectClassWrapper) firstElement).getParent(); if (parent instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) parent).getParent()).getSchema(); } else if (parent instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) parent).getSchema(); } } } } // Instantiates and initializes the wizard NewAttributeTypeWizard wizard = new NewAttributeTypeWizard(); wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); wizard.setSelectedSchema(selectedSchema); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.create(); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.NewObjectClassAction.java
License:Apache License
/** * {@inheritDoc}/*from ww w . j a va2 s . c o m*/ */ public void run() { // Getting the selection Schema selectedSchema = null; int presentation = Activator.getDefault().getPreferenceStore() .getInt(PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION); if (presentation == PluginConstants.PREFS_SCHEMA_VIEW_SCHEMA_PRESENTATION_FLAT) { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() == 1)) { Object firstElement = selection.getFirstElement(); if (firstElement instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) firstElement).getSchema(); } else if (firstElement instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) firstElement).getParent()).getSchema(); } else if (firstElement instanceof AttributeTypeWrapper) { TreeNode parent = ((AttributeTypeWrapper) firstElement).getParent(); if (parent instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) parent).getParent()).getSchema(); } else if (parent instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) parent).getSchema(); } } else if (firstElement instanceof ObjectClassWrapper) { TreeNode parent = ((ObjectClassWrapper) firstElement).getParent(); if (parent instanceof Folder) { selectedSchema = ((SchemaWrapper) ((Folder) parent).getParent()).getSchema(); } else if (parent instanceof SchemaWrapper) { selectedSchema = ((SchemaWrapper) parent).getSchema(); } } } } // Instantiates and initializes the wizard NewObjectClassWizard wizard = new NewObjectClassWizard(); wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY); wizard.setSelectedSchema(selectedSchema); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.create(); dialog.open(); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.OpenElementAction.java
License:Apache License
/** * Creates a new instance of DeleteSchemaElementAction. *//*from w w w . ja v a 2 s . c o m*/ public OpenElementAction(TreeViewer viewer) { super(Messages.getString("OpenElementAction.OpenAction")); //$NON-NLS-1$ setToolTipText(Messages.getString("OpenElementAction.OpenToolTip")); //$NON-NLS-1$ setId(PluginConstants.CMD_OPEN_ELEMENT); setActionDefinitionId(PluginConstants.CMD_OPEN_ELEMENT); setEnabled(false); this.viewer = viewer; this.viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (selection.size() > 0) { boolean enabled = true; for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) { Object selectedItem = iterator.next(); if (!(selectedItem instanceof SchemaWrapper) && !(selectedItem instanceof AttributeTypeWrapper) && !(selectedItem instanceof ObjectClassWrapper)) { enabled = false; break; } } setEnabled(enabled); } else { setEnabled(false); } } }); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.OpenProjectAction.java
License:Apache License
/** * Enables or disables the Action.//from ww w .j av a 2 s. c o m */ private void enableDisable() { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() == 1)) { setEnabled(((ProjectWrapper) selection.getFirstElement()).getProject().getState() .equals(ProjectState.CLOSED)); } else { setEnabled(false); } }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.OpenProjectAction.java
License:Apache License
/** * {@inheritDoc}/*from w ww. ja va2s . c o m*/ */ public void run() { StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if ((!selection.isEmpty()) && (selection.size() == 1)) { projectsHandler.openProject(((ProjectWrapper) selection.getFirstElement()).getProject()); } }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.OpenTypeHierarchyAction.java
License:Apache License
/** * Creates a new instance of DeleteSchemaElementAction. *//*from w w w.j a va 2s.c om*/ public OpenTypeHierarchyAction(TreeViewer viewer) { super(Messages.getString("OpenTypeHierarchyAction.OpenTypeAction")); //$NON-NLS-1$ setToolTipText(Messages.getString("OpenTypeHierarchyAction.OpenTypeToolTip")); //$NON-NLS-1$ setId(PluginConstants.CMD_OPEN_TYPE_HIERARCHY); setActionDefinitionId(PluginConstants.CMD_OPEN_TYPE_HIERARCHY); setEnabled(false); this.viewer = viewer; this.viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); setEnabled((selection.size() == 1) && ((selection.getFirstElement() instanceof AttributeTypeWrapper) || (selection.getFirstElement() instanceof ObjectClassWrapper))); } }); }
From source file:org.apache.directory.studio.schemaeditor.controller.actions.RenameProjectAction.java
License:Apache License
/** * Creates a new instance of RenameProjectAction. * * @param view/*from w ww .ja v a 2s. c o m*/ * the associate view */ public RenameProjectAction(TableViewer viewer) { super(Messages.getString("RenameProjectAction.RenameProjectAction")); //$NON-NLS-1$ setToolTipText(getText()); setId(PluginConstants.CMD_RENAME_PROJECT); setActionDefinitionId(PluginConstants.CMD_RENAME_PROJECT); setImageDescriptor(Activator.getDefault().getImageDescriptor(PluginConstants.IMG_RENAME)); setEnabled(false); this.viewer = viewer; this.viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); setEnabled(selection.size() == 1); } }); projectsHandler = Activator.getDefault().getProjectsHandler(); }