Package org.locationtech.udig.catalog.document.IHotlinkSource

Examples of org.locationtech.udig.catalog.document.IHotlinkSource.HotlinkDescriptor


         * @param parentShell
         */
        protected HotlinkDescriptorDialog(Shell parentShell) {
            super(parentShell);
            this.isAddMode = true;
            this.descriptor = new HotlinkDescriptor();
        }
View Full Code Here


                }
                String description = descriptionText.getText();
                StructuredSelection selection = (StructuredSelection) typeViewer.getSelection();
                ContentType type = (ContentType) selection.getFirstElement();
                final String actionConfig = actionText.getText();
                descriptor = new HotlinkDescriptor(label, description, attributeName, type, actionConfig);
                super.okPressed();               
            }
           
        }
View Full Code Here

        infoGoAction = new ComboViewer(composite, SWT.READ_ONLY | SWT.DROP_DOWN);
        infoGoAction.getControl().setLayoutData("split 2"); //$NON-NLS-1$
        infoGoAction.setLabelProvider(new LabelProvider() {
            @Override
            public String getText(Object element) {
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                return descriptor.getLabel();
            }
        });
        infoGoAction.setContentProvider(ArrayContentProvider.getInstance());
        infoGoAction.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                final StructuredSelection selection = (StructuredSelection) event.getSelection();
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();
                label.setText(descriptor.getLabel());
                final String descriptionStr = descriptor.getDescription();
                if (descriptionStr == null) {
                    description.setText("");     //$NON-NLS-1$
                } else {
                    description.setText(descriptionStr);
                }
            }
        });
        final List<HotlinkDescriptor> actions = getActions();
        if (actions != null && actions.size() > 0) {
            infoGoAction.setInput(actions.toArray());
        }
       
        infoGoActionBtn = new Button(composite, SWT.PUSH);
        infoGoActionBtn.setText(Messages.DocumentDialog_goBtn);
        infoGoActionBtn.setLayoutData(""); //$NON-NLS-1$
        infoGoActionBtn.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                final StructuredSelection selection = (StructuredSelection) infoGoAction.getSelection();
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();
                final String action = descriptor.getConfig().replace(
                        DocumentPropertyPage.ACTION_PARAM, info.getText());
                Program.launch(action);
            }
        });
       
View Full Code Here

            dialog.setTitle(Messages.DocumentView_openActionDialogTitle);
            dialog.setMessage(Messages.DocumentView_openActionDialogMessage);
            dialog.setLabelProvider(new LabelProvider() {
                @Override
                public String getText(Object element) {
                    final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                    return DocUtils.getLabelAndDescDisplay(descriptor.getLabel(),
                            descriptor.getDescription());
                }
            });
            dialog.setContentProvider(new ArrayContentProvider());
            dialog.setInput(descriptors.toArray());
            dialog.setInitialElementSelections(Collections.singletonList(descriptors.get(0)));
            if (Dialog.OK == dialog.open()) {
                final Object[] results = dialog.getResult();
                if (results != null && results.length > 0) {
                    final HotlinkDescriptor descriptor = (HotlinkDescriptor) results[0];
                    openAction(hotlinkDoc, descriptor);
                }
            }           
        } else if (descriptors.size() == 1) {
            final HotlinkDescriptor descriptor = descriptors.get(0);
            openAction(hotlinkDoc, descriptor);
        }
       
    }
View Full Code Here

    private List<HotlinkDescriptor> toHotlinkDescriptorList(String spec) {
        if (spec != null && !spec.isEmpty()) {
            final List<HotlinkDescriptor> descriptors = new ArrayList<HotlinkDescriptor>();
            final String[] desriptorArray = spec.split(DELIMITER_REGEX);
            for (String descriptor : desriptorArray) {
                descriptors.add(new HotlinkDescriptor(descriptor));
            }
            return descriptors;
        }
        return null;
    }
View Full Code Here

            public String getText(Object element) {
                return ""; //$NON-NLS-1$
            }
            @Override
            public Image getImage(Object element) {
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                switch (descriptor.getType()) {
                case FILE:
                    return PlatformUI.getWorkbench().getSharedImages()
                            .getImage(ISharedImages.IMG_OBJ_FILE);
                case WEB:
                    return InfoPlugin.getDefault().getImageRegistry()
                            .get(InfoPlugin.IMG_OBJ_LINK);
                case ACTION:
                    return InfoPlugin.getDefault().getImageRegistry()
                            .get(InfoPlugin.IMG_OBJ_ACTION);
                default:
                    break;
                }
                return PlatformUI.getWorkbench().getSharedImages()
                        .getImage(ISharedImages.IMG_OBJ_ELEMENT);
            }
        });
        columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(8, 0, false));
       
        column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
        column.getColumn().setText(Messages.Document_Label_Column);
        column.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                return descriptor.getLabel();
            }
        });
        columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(25, 0, true));
       
        column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
        column.getColumn().setText(Messages.Document_Attribute_Column);
        column.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
                HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                return descriptor.getAttributeName();
            }
        });
        columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 25, 0, true ));
       
        column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
        column.getColumn().setText(Messages.Document_Hotlink_Column);
        column.getColumn().setAlignment(SWT.CENTER);
        column.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
                HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                return DocUtils.toCamelCase(descriptor.getType().toString());
            }
        });
        columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 15, 0, true ));
       
        column = new TableViewerColumn(hotlinkViewer, SWT.NONE);
        column.getColumn().setText(Messages.Document_Action_Column);
        column.setLabelProvider(new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
                HotlinkDescriptor descriptor = (HotlinkDescriptor) element;
                if( descriptor.getConfig() == null ){
                    return Messages.DocumentPropertyPage_Open;
                }
                return descriptor.getConfig();
            }
        });
        columnLayout.setColumnData( column.getColumn(), new ColumnWeightData( 30, 0, true ));
       
        hotlinkViewer.getTable().setHeaderVisible(true);
        hotlinkViewer.getTable().setLinesVisible(true);
        hotlinkViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                ISelection sel = event.getSelection();
                editHotlink.setEnabled(!sel.isEmpty());
                removeButton.setEnabled(!sel.isEmpty());
            }
        });
        hotlinkViewer.addDoubleClickListener(new IDoubleClickListener() {
            @Override
            public void doubleClick(DoubleClickEvent event) {
                final StructuredSelection selection = (StructuredSelection) hotlinkViewer.getSelection();
                final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();
                editDescriptor(descriptor);
            }
        });
       
    }
View Full Code Here

            @Override
            public void widgetSelected(SelectionEvent e) {
                ISelection sel = hotlinkViewer.getSelection();
                if (!sel.isEmpty() && sel instanceof StructuredSelection) {
                    StructuredSelection selection = (StructuredSelection) sel;
                    HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();

                    int index = hotlinkList.indexOf(descriptor);
                    addDescriptor(index);
                } else {
                    addDescriptor(-1);
                }
            }
        });

        editHotlink = new Button(buttonComposite, SWT.CENTER);
        editHotlink.setText(Messages.Document_Edit);
        editHotlink.setLayoutData(""); //$NON-NLS-1$
        editHotlink.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                ISelection sel = hotlinkViewer.getSelection();
                if (!sel.isEmpty() && sel instanceof StructuredSelection) {
                    StructuredSelection selection = (StructuredSelection) sel;
                    HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();
                    editDescriptor(descriptor);
                }
            }
        });

        removeButton = new Button(buttonComposite, SWT.CENTER);
        removeButton.setText(Messages.Document_Remove);
        removeButton.setLayoutData(""); //$NON-NLS-1$
        removeButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                ISelection sel = hotlinkViewer.getSelection();
                if (!sel.isEmpty() && sel instanceof StructuredSelection) {
                    StructuredSelection selection = (StructuredSelection) sel;
                    HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement();

                    removeDescriptor(descriptor);
                }
            }
        });
View Full Code Here

        final int index = hotlinkViewer.getTable().getSelectionIndex();
       
        // look up shell now from the display thread
        final Shell shell = DocumentPropertyPage.this.getShell();
       
        final HotlinkDescriptor copy = new HotlinkDescriptor(descriptor);
        final HotlinkDescriptorDialog prompt = new HotlinkDescriptorDialog(shell, copy);
        prompt.openInJob(new Runnable() {
            @Override
            public void run() {
                HotlinkDescriptor edited = prompt.getDescriptor();
                if (edited != null && !edited.isEmpty()) {
                    hotlinkList.set(index, edited);
                    hotlinkViewer.refresh();
                    hotlinkViewer.setSelection( new StructuredSelection( edited ) );
                }
            }
View Full Code Here

        final Shell shell = DocumentPropertyPage.this.getShell();
        final HotlinkDescriptorDialog prompt = new HotlinkDescriptorDialog(shell);
        prompt.openInJob(new Runnable() {
            @Override
            public void run() {
                HotlinkDescriptor created = prompt.getDescriptor();
                if (created != null && !created.isEmpty()) {
                    if (index == -1 ) {
                        hotlinkList.add(created); // append to end
                    } else {
                        int insert = index +0;
                        if( insert < hotlinkList.size() ){
View Full Code Here

        final List<HotlinkDescriptor> descriptors = new ArrayList<HotlinkDescriptor>();
        if (definitions != null && !definitions.isEmpty()) {
            final String definitionArray[] = definitions.split(HOTLINK_DELIMITER_REGEX);
            for (String definition : definitionArray) {
                try {
                    HotlinkDescriptor descriptor = new HotlinkDescriptor(definition);
                    descriptors.add(descriptor);
                } catch (Throwable t) {
                    InfoPlugin.log("Unable describe hotlink:" + definition, t); //$NON-NLS-1$
                }
            }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.catalog.document.IHotlinkSource.HotlinkDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.